<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<p:dialog xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" 
	xmlns:pe="http://primefaces.org/ui/extensions"
	xmlns:of="http://omnifaces.org/functions"
	modal="true" width="630" height="520" resizable="false" 
	widgetVar="dialogAddServico" id="dialogServico" closable="false"
	appendToBody="true">

	<link type="text/css" rel="stylesheet" href="../../resources/css/style.css" />
	
	<f:facet name="header">
		<h:outputText value="Cadastrar Serviço" />
	</f:facet>
	
	<h:form id="formAddServico" prependId="false">
		<p:messages id="messageFormServico" autoUpdate="true"/>
		
		<h:panelGrid columns="2" style="padding:5px;">
			<h:outputText value="Código" />
			<h:outputText value="Descrição *" />
			
			<p:inputText style="width:100px;" disabled="true" value="#{agendamentoBean.newServico.id}"/>
			<p:inputText style="width:410px;" value="#{agendamentoBean.newServico.descricao}" required="true" requiredMessage="Informe a descrição." maxlength="40"/>
		</h:panelGrid>
	
		<h:panelGrid columns="4" style="padding:5px;">			
			<h:outputText value="Valor mão de obra" />			
			<h:outputText value="Valor do serviço *" />	
			<h:outputText value="Comissão" />	
			<h:outputText value="Tempo médio" />
			
			<pe:inputNumber style="width:120px;" value="#{agendamentoBean.newServico.valorMaoObra}" decimalSeparator="," decimalPlaces="2"  thousandSeparator="." maxValue="100000"/>
			<pe:inputNumber style="width:120px;" value="#{agendamentoBean.newServico.valorServico}" decimalSeparator="," decimalPlaces="2"  thousandSeparator="." required="true" requiredMessage="Informe o valor do serviço." maxValue="100000"/>
			<pe:inputNumber style="width:120px;" value="#{agendamentoBean.newServico.comissao}" decimalSeparator="," decimalPlaces="2"  thousandSeparator="." maxValue="100000"/>
			<pe:inputNumber style="width:120px;" value="#{agendamentoBean.newServico.tempoMedio}" decimalPlaces="0" maxValue="100000"/>
		</h:panelGrid>

		<h:panelGrid columns="1" style="padding:5px;">	
			<h:outputText value="Observações" />		
			<p:inputTextarea style="width:520px; height:80px;" value="#{agendamentoBean.newServico.observacao}" maxlength="255"/>	
		</h:panelGrid>

		<h:panelGrid columns="1" style="padding:5px;">
			<h:outputText value="* Campos obrigatórios" />
		</h:panelGrid>
		
		<div style="width:100%; display: inline-block;">
			<p:commandButton icon="ui-icon-search" value="Adicionar funcionário" 
				actionListener="#{agendamentoBean.openDialogListFuncionarioAddServico}" immediate="true"
				style="float:right;"/>
		</div>
		<div style="padding-top:10px;">
			<p:dataTable var="funcionario" style="width:600px;"
				value="#{agendamentoBean.currentFuncionarios}" 
				paginator="true" rows="3" paginatorPosition="bottom"
				emptyMessage="Não há registros" id="tableFuncionarios">
				  
				<p:column headerText="Código" style="width:80px;">  
			    	<h:outputText value="#{funcionario.id}" />  
				</p:column>  
			 
				<p:column headerText="Nome">  
			    	<h:outputText value="#{of:abbreviate(funcionario.nome, 60)}" />  
				</p:column> 	
	
				<p:column width="50" style="text-align:center;">
					<p:commandButton icon="ui-icon-trash"
						style="width: 24px; height: 24px;" 
						actionListener="#{agendamentoBean.removeFuncionario(funcionario.id)}" title="Remover"
						immediate="true"/>
					</p:column>
		  	</p:dataTable>
		</div>
		
		<div id="popup-buttons" style="padding-bottom: 10px; padding-top: 10px; text-align: right;">
			<p:commandButton value="Salvar" style="height:28px;" update="formAddServico, messageFormServico" actionListener="#{agendamentoBean.saveServicoFromDialog}" icon="ui-icon-disk"/>
			<p:commandButton value="Cancelar" style="height:28px;" actionListener="#{agendamentoBean.closeDialogAddServico}" immediate="true" icon="ui-icon-cancel"/>
		</div>
	</h:form>
</p:dialog>